module.exports = function associate(models) {
  const {
    user,
    doctor_info,
    department_and_disease,
    pb,
    applys,
    valid_faild,
    question,
  } = models;

  doctor_info.belongsTo(user, {
    as: "user",
    foreignKey: "u_id",
  });

  doctor_info.belongsTo(pb, {
    as: "pb_date",
    foreignKey: "pb_date_id",
  });

  doctor_info.belongsTo(pb, {
    as: "pb_time",
    foreignKey: "pb_time_id",
  });

  doctor_info.belongsTo(department_and_disease, {
    as: "department",
    foreignKey: "department_id",
  });

  doctor_info.belongsTo(department_and_disease, {
    as: "disease",
    foreignKey: "disease_id",
  });

  applys.belongsTo(user, {
    as: "applyer",
    foreignKey: "u_id",
  });

  applys.belongsTo(user, {
    as: "doctor",
    foreignKey: "d_id",
  });

  applys.belongsTo(department_and_disease, {
    as: "department",
    foreignKey: "department_id",
  });

  applys.belongsTo(department_and_disease, {
    as: "disease",
    foreignKey: "disease_id",
  });

  valid_faild.belongsTo(user, {
    as: "doctor",
    foreignKey: "d_id",
  });

  department_and_disease.belongsTo(department_and_disease, {
    foreignKey: "father_id",
  });

  question.hasMany(question, {
    as: "replys",
    foreignKey: "zone",
  });

  question.belongsTo(user, {
    as: "from_user",
    foreignKey: "from",
  });

  question.belongsTo(user, {
    as: "to_user",
    foreignKey: "to",
  });
};
